package cn.t.persistence.mapper.user;

import cn.t.persistence.entity.user.RoleInfoPO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * 角色信息表领域对象与实体对象转换
 *
 * @author l
 */

public interface RoleInfoMapper extends BaseMapper<RoleInfoPO> {

    @Select("select t.* from t_role_info t where t.id = #{roleId} and t.status = 1 and t.is_deleted = 'N' " +
            " and exists ( select 1 from t_role_firm rf where t.id = rf.role_id and rf.firm_id = #{firmId} and rf.status = 1 and rf.is_deleted = 'N' )")
    List<RoleInfoPO> findByFirmAndId(Long firmId, Long roleId);

    @Select("select t.* from t_role_info t where t.role_name = #{roleName} and t.status = 1 and t.is_deleted = 'N' " +
            " and exists ( select 1 from t_role_firm rf where t.id = rf.role_id and rf.firm_id = #{firmId} and rf.status = 1 and rf.is_deleted = 'N' )")
    List<RoleInfoPO> getRoleInfoByNameAndFirm(String roleName, Long firmId);
}
